﻿using Configs;
using Utils;

namespace Modules.Game
{
    public class GameModel : Singleton<GameModel>
    {
        public bool IsGaming = true;
        public int MaxScore;

        public int Score;

        private GameModel()
        {
            Score = 0;
            MaxScore = StorageUtil.LoadInt(StorageConfig.MaxScore);
        }

        public void OnGameOver()
        {
            IsGaming = false;
            if (Score > MaxScore)
            {
                MaxScore = Score;
                StorageUtil.SaveInt(StorageConfig.MaxScore, Score);
            }
        }

        /// <summary>
        ///     游戏重开
        /// </summary>
        public void GameRestart()
        {
            Instance.IsGaming = true;
            Score = 0;
        }
    }
}